package com.activemq.spring;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
public class SpringProduce {
    @Resource
    private JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        SpringProduce springProduce = ctx.getBean("springProduce", SpringProduce.class);
        springProduce.jmsTemplate.send(session -> session.createTextMessage("测试spring-topic-2"));
        log.info("发布完成");
    }
}
